import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//路由懒加载
 const Home = () => import(/* webpackChunkName: "home" */ '@/pages/home/index.vue')
 const Category = () => import(/* webpackChunkName: "category" */ '@/pages/category/index.vue')
 const Active = () => import(/* webpackChunkName: "active" */ '@/pages/active/index.vue')
 const Cart = () => import(/* webpackChunkName: "cart" */ '@/pages/cart/index.vue')
 const Mine = () => import(/* webpackChunkName: "mine" */ '@/pages/mine/index.vue')
 const Hot = () => import(/* webpackChunkName: "hot" */ '@/pages/home/Hot.vue')
 const Cinema = () => import(/* webpackChunkName: "cinema" */ '@/pages/home/Cinema.vue')
 const Coming = () => import(/* webpackChunkName: "coming" */ '@/pages/home/Coming.vue')
 const Classic = () => import(/* webpackChunkName: "classic" */ '@/pages/home/Classic.vue')
 const City = () => import(/* webpackChunkName: "city" */ '@/pages/city/index.vue')
 const Search = () => import(/* webpackChunkName: "search" */ '@/pages/search/index.vue')
 const Error = () => import(/* webpackChunkName: "erroe" */ '@/pages/404/index.vue')


 const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)}
export default new VueRouter({
    mode: 'history',
    routes: [
        {
            path: '/',
            component: Home
        },
        {
            path: '/home',
            component: Home,
            children:[
                {
                    path:'hot',
                    component:Hot
                },
                {
                    path:'cinema',
                    component:Cinema
                },
                {
                    path:'coming',
                    component:Coming
                },
                {
                    path:'classic',
                    component:Classic
                },
            ]
        },
        {
            path: '/category',
            component: Category
        },
        {
            path: '/active',
            component: Active
        },
        {
            path: '/cart',
            component: Cart
        },
        {
            path: '/mine',
            component: Mine
        },
        {
            path: '/city',
            component: City
        },
        {
            path: '/search',
            component: Search
        },
        {
            path: '*',
            component: Error
        }
    ]
})